# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=openjpeg
pkgver=2.5.2
pkgrel=0
pkgdesc="Open-source implementation of JPEG2000 image codec"
url="https://www.openjpeg.org/"
arch="all"
options="!check"  # No test suite.
license="BSD-2-Clause"
# Some of the development CMake files installed by -dev depend on tools provided by the -tools subpackage
depends_dev="$pkgname-tools"
makedepends="libpng-dev tiff-dev lcms2-dev doxygen cmake samurai"
subpackages="$pkgname-dev $pkgname-tools"
source="https://github.com/uclouvain/openjpeg/archive/v$pkgver/openjpeg-v$pkgver.tar.gz
	"

# secfixes:
#   2.5.0-r0:
#     - CVE-2021-3575
#     - CVE-2022-1122
#   2.4.0-r1:
#     - CVE-2021-29338
#   2.4.0-r0:
#     - CVE-2020-27844
#   2.3.1-r6:
#     - CVE-2020-27814
#     - CVE-2020-27823
#     - CVE-2020-27824
#   2.3.1-r5:
#     - CVE-2019-12973
#     - CVE-2020-15389
#   2.3.1-r3:
#     - CVE-2020-6851
#     - CVE-2020-8112
#   2.3.0-r3:
#     - CVE-2018-5785
#   2.3.0-r2:
#     - CVE-2018-14423
#     - CVE-2018-6616
#   2.3.0-r1:
#     - CVE-2017-17480
#     - CVE-2018-18088
#   2.3.0-r0:
#     - CVE-2017-14039
#   2.2.0-r2:
#     - CVE-2017-14040
#     - CVE-2017-14041
#     - CVE-2017-14151
#     - CVE-2017-14152
#     - CVE-2017-14164
#   2.2.0-r1:
#     - CVE-2017-12982
#   2.1.2-r1:
#     - CVE-2016-9580
#     - CVE-2016-9581

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DOPENJPEG_INSTALL_LIB_DIR=lib
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

tools() {
	pkgdesc="$pkgdesc - tools"
	amove usr/bin
}

sha512sums="
24c058b3e0710e689ba7fd6bce8a88353ce64e825b2e5bbf6b00ca3f2a2ec1e9c70a72e0252a5c89d10c537cf84d55af54bf2f16c58ca01db98c2018cf132e1a  openjpeg-v2.5.2.tar.gz
"
